import { Node, Shape } from "@antv/x6";
import CommitNodeIcon from '../icons/StartEvent.svg';
import lodash from 'lodash';

export default class CommitNode extends Shape.Rect{
  private static default:Node.Metadata = {
    width: 100,
    height: 60,
    label: '流程启动',
    markup: [
      { tagName: 'rect', selector: 'body' },
      { tagName: 'image', selector: 'img' },
      { tagName: 'text', selector: 'label' },
    ],
    attrs: {
      body: {
        rx: 6,
        ry: 6,
        stroke: '#EFD0FF',
        fill: '#EFD0FF',
        strokeWidth: 10,
      },
      img: {
        x: 6,
        y: 6,
        width: 18,
        height: 18,
        'xlink:href': CommitNodeIcon
      },
      label: {
        fontSize: 12,
        fill: '#262626',
      },
    },
    data:{
      tag: 'userTask',
      assignee: '#{INITIATOR}'
    }
  }
  private static complement = (metadata: Node.Metadata={}):Node.Metadata=>{
    const adds = {} as Node.Metadata;
    adds.id = 'COMMIT';
    return lodash.mergeWith({},CommitNode.default,metadata,adds);
  }

  constructor(metadata: Node.Metadata={}){
    super(CommitNode.complement(metadata));
  }

}